package com.joysuch.wwyt.app.controller;

import com.joysuch.wwyt.bp.bean.BpStoreMaterialBean;
import com.joysuch.wwyt.bp.bean.BpStoreMaterialSearchBean;
import com.joysuch.wwyt.bp.service.BpStoreHouseService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xsx
 * @version 1.0
 * @date 2022/9/16 16:26
 */
@RestController
@RequestMapping("/bp/app/house/pageMaterial")
@CrossOrigin
@Api(tags = "/bp/app/house/pageMaterial 应急物资")
public class AppStoreHouseController {


    @Autowired
    private BpStoreHouseService bpStoreHouseService;


    @GetMapping("pageMaterial")
    @ApiOperation(value = "分页展示物资")
    public ResultBean pageMaterial(Pageable pageable,  BpStoreMaterialSearchBean condition) {
        return bpStoreHouseService.pageNewMaterial(pageable,condition);
    }

    @GetMapping("getMaterialById")
    @ApiOperation(value = "查看物资")
    public ResultBean getMaterialById(Long id) {
        try {
            BpStoreMaterialBean bean = bpStoreHouseService.getMaterialById(id);
            return ResultBean.success(bean);
        } catch (Exception e) {
            return ResultBean.fail(101, "查看失败");
        }
    }
}
